home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nejlepší hry
/
Nejlepsi hry.iso
/
hry
/
sea of chaos
/
sea_install.msi
/
_15C39AAA7726369D39812BD40F01CF6A
/
_AAC4B543D1064DADAEC7C433BC3227AB
< prev
next >
Wrap
Text File
|
2005-02-15
|
1KB
|
64 lines
//extrudes an object away from a light, for faces away from the light
//Luke Lenhart
//(C)2004-2005 Digipen Institute of Technology
//...shadows depreciated...
//world,view,projection transforms
float4x4 matWorld, matViewProj;
//light position (in world space)
float4 lightPos;
//shader input
struct VS_INPUT
{
float4 Pos : POSITION;
float4 Normal : NORMAL;
//float2 Tex0 : TEXCOORD0;
};
//shader output
struct VS_OUTPUT
{
float4 Pos : POSITION;
//float2 Tex0 : TEXCOORD0;
//float4 Color : COLOR;
};
//shader code
VS_OUTPUT VShader(VS_INPUT In)
{
VS_OUTPUT Out;
//move us to world space
In.Pos.xyz-=In.Normal.xyz*0.25f; //pull in tiny bit so wrong surfaces don't get shadowed
float4 pos=mul(matWorld,In.Pos);
float4 norm=mul(matWorld,In.Normal.xyz);
const float EXTRUDE_DIST=10000.0f;
//calc direction from light to vert
float3 rayDir=normalize(pos.xyz-lightPos.xyz);
//stuff on the back side should be extruded
float sideCheck=dot(norm,rayDir);
if (sideCheck>0) //back side
{
//push vert in direction of ray
pos.xyz+=rayDir*EXTRUDE_DIST;
}
//calc transformed position
Out.Pos=mul(matViewProj,pos);
//copy tex coord
//Out.Tex0=In.Tex0;
//plain color
//Out.Color=float4(1,1,1,1);
//spit out the results
return Out;
}